$("#edit_button").click(function(){
	var son=$("#id").text();
	var sname=$("#name").val();
	var age=$("#age").val();
	var sex=$("#sex").val();
	var sdept=$("#dept").val();
	//alert(son+" "+sname+" "+age+" "+sex+" "+sdept);
   $.ajax(
   {
   url:"update",
   method:"post",
   data:{
   id:son,
   name:sname,
   age:age,
   sex:sex,
   dept:sdept
   },
   dataType:"json",
   success:function(data){
   if(data.status=="success")
   window.location.reload();
   else if(data.status="fail")alert("fail");
   },
   error:function(data){alert("no");}
    });
  });
 
 $("#insert_li").click(function(){
  $("#insert").show();
  });
  $("#insert_button").click(function(){
  var son=$("#insert_id").val();
  var sname=$("#insert_name").val();
  var age=$("#insert_age").val();
  var sex=$("#insert_sex").val();
  var sdept=$("#insert_dept").val();
  alert(son+" "+sname+" "+age+" "+sex+" "+sdept);
 $.ajax(
   {
   url:"insert",
   method:"post",
   data:{
   id:son,
   name:sname,
   age:age,
   sex:sex,
   dept:sdept
   },
   dataType:"json",
   success:function(data){
   if(data.status=="success")
   window.location.reload();
   else if(data.status="fail")alert("fail");
   },
   error:function(data){alert("no");}
    });
  });
  
  $("#search_li").click(function(){
  $("#search").show();
  });
  
  $("#search_button").click(function(){ 
  
  var son=$("#search_id").val();
  $.ajax({
  url:"searchById",
  method:"post",
  data:{id:son},
  dataType:"json",
  success:function(data){if(data.status=="success")
  {
  $("#search_name").text(data.user.sname);
  $("#search_sex").text(data.user.ssex);
  $("#search_age").text(data.user.sage);
  $("#search_dept").text(data.user.sdept);
  }
  },
  error:function(data){alert("error");}
  });
  });
  
$("#close_insert").click(function(){
$("#insert").hide();
});
 $("#close_search").click(function(){
$("#search").hide();
});
$("#close_edit").click(function(){
$("#edit").hide();
});
